package com.nuo.backend.common.threadlocal;

import com.nuo.backend.common.utils.JwtUtils;
import com.nuo.backend.modules.security.entity.SecUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description: TODO 通过请求头中的 jwt/token 获取当前登陆的用户信息
 * @author nuo
 * @date 2022/12/3 19:11
 * @version 1.0
 */
@Component
public class SecUserThreadLocal {


    private static final ThreadLocal<SecUserEntity> threadLocal = new ThreadLocal<>();

    public void set(SecUserEntity secUser) {
        threadLocal.set(secUser);
    }

    public SecUserEntity get() {
        return threadLocal.get();
    }

    public void remove() {
        threadLocal.remove();
    }
}
